#include <iostream>
using namespace std;

int next[1000];

int getnext(string s)
{
	next[0]=0;
	next[1]=0;
	int j=0;
	for(int i=1;i<s.length();i++){
		while(j>0&&s[j]!=s[i]) j=next[j];
		if(s[j]==s[i])j++;
		next[i+1]=j;
	}
} 
int main()
{
	string s;
	while(cin>>s){
		getnext(s);
		for(int i=1;i<=s.length();i++) cout<<next[i]<<" ";
		cout<<endl;
	}
}
